<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<System.Web.Security.MembershipUserCollection>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	List of Users
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<h2>
		List of Users</h2>

	<script src="../../Scripts/jquery-1.3.2.js" type="text/javascript"></script>

	<script type="text/javascript">
		function ResetPassword(userName) {
			$.get("/Account/ResetPassword",
				{ userName: userName },
				function(newPassword) {
					alert("New password is: " + newPassword);
				});
		}
	</script>

	<table>
		<tr>
			<th>
			</th>
			<th>
				User Name
			</th>
			<th>
				Creation Date
			</th>
			<th>
				Email
			</th>
			<th>
				Is Online
			</th>
			<th>
				Last Login Date
			</th>
			<th>
				Role
			</th>
		</tr>
		<% foreach (MembershipUser user in Model)
		 {%>
		<tr>
			<td>
				<a href="#" onclick="ResetPassword('<%= user.UserName %>')">Reset Password</a>
			</td>
			<td>
				<%= Html.Encode(user.UserName) %>
			</td>
			<td>
				<%= Html.Encode(user.CreationDate )%>
			</td>
			<td>
				<%= Html.Encode(user.Email)%>
			</td>
			<td>
				<%= Html.Encode(user.IsOnline)%>
			</td>
			<td>
				<%= Html.Encode(user.LastLoginDate )%>
			</td>
			<td>
				<%= Html.Encode(Roles.GetRolesForUser(user.UserName).FirstOrDefault())%>
			</td>
		</tr>
		<%} %>
	</table>
</asp:Content>
